package com.ruoyi.stock.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.stock.domain.QwStockdayinfo;
import com.ruoyi.stock.service.IQwStockdayinfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 每日股票信息Controller
 * 
 * @author ruoyi
 * @date 2023-08-16
 */
@RestController
@RequestMapping("/stock/stockdayinfo")
public class QwStockdayinfoController extends BaseController
{
    @Autowired
    private IQwStockdayinfoService qwStockdayinfoService;

    /**
     * 查询每日股票信息列表
     */
    @PreAuthorize("@ss.hasPermi('stock:stockdayinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(QwStockdayinfo qwStockdayinfo)
    {
        startPage();
        List<QwStockdayinfo> list = qwStockdayinfoService.selectQwStockdayinfoList(qwStockdayinfo);
        return getDataTable(list);
    }

    /**
     * 导出每日股票信息列表
     */
    @PreAuthorize("@ss.hasPermi('stock:stockdayinfo:export')")
    @Log(title = "每日股票信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QwStockdayinfo qwStockdayinfo)
    {
        List<QwStockdayinfo> list = qwStockdayinfoService.selectQwStockdayinfoList(qwStockdayinfo);
        ExcelUtil<QwStockdayinfo> util = new ExcelUtil<QwStockdayinfo>(QwStockdayinfo.class);
        util.exportExcel(response, list, "每日股票信息数据");
    }

    /**
     * 获取每日股票信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('stock:stockdayinfo:query')")
    @GetMapping(value = "/{dayInfoId}")
    public AjaxResult getInfo(@PathVariable("dayInfoId") Long dayInfoId)
    {
        return success(qwStockdayinfoService.selectQwStockdayinfoByDayInfoId(dayInfoId));
    }

    /**
     * 新增每日股票信息
     */
    @PreAuthorize("@ss.hasPermi('stock:stockdayinfo:add')")
    @Log(title = "每日股票信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QwStockdayinfo qwStockdayinfo)
    {
        return toAjax(qwStockdayinfoService.insertQwStockdayinfo(qwStockdayinfo));
    }

    /**
     * 修改每日股票信息
     */
    @PreAuthorize("@ss.hasPermi('stock:stockdayinfo:edit')")
    @Log(title = "每日股票信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QwStockdayinfo qwStockdayinfo)
    {
        return toAjax(qwStockdayinfoService.updateQwStockdayinfo(qwStockdayinfo));
    }

    /**
     * 删除每日股票信息
     */
    @PreAuthorize("@ss.hasPermi('stock:stockdayinfo:remove')")
    @Log(title = "每日股票信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dayInfoIds}")
    public AjaxResult remove(@PathVariable Long[] dayInfoIds)
    {
        return toAjax(qwStockdayinfoService.deleteQwStockdayinfoByDayInfoIds(dayInfoIds));
    }
}
